<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <title>创建战队</title>
    <link rel="stylesheet" type="text/css" media="screen" href="{$staticHost}/static/css/base.css?v=14" />
    <link rel="stylesheet" type="text/css" media="screen" href="{$staticHost}/static/css/run.css?v=130" />
    <script src="{$staticHost}/static/js/jquery.min.js"></script>
    <script src="{$staticHost}/static/js/jquery.cityselect.js"></script>
</head>
<body class="club-bg">
<form class="form-horizontal"  action="?c=paome_webIndex&a=addClub"  id="tr_form" enctype="multipart/form-data" onsubmit="return false;">
  <header id="img_con">
    <label>
      <img class="upLoad_btn" src=""/>
      上传战队LOGO
      <div class="fileDiv"><input type="file" hidden="" name="myfile" id="myfile" multiple="true" onchange="upload(this)"></div>
    </label>
  </header>
  <section>
    <div class="bg-tm"><span class="load load-ios"></span></div>
    <h5>战队名称：</h5>
    <input placeholder="给您的战队起个霸气的昵称吧" type="text" name="name">

    <h5>所属城市</h5>
    <div id="city">
      <select class="prov" name="provice"></select>
      <select class="city" disabled="disabled" name="city"></select>
    </div>
    <h5>战队简介：</h5>
    <textarea placeholder="写一段战队简介让其他人更好的了解你的战队" name="content"></textarea>
    <p class="color-blue ptb20 ac f16">需要消耗正能量：100</p>
    <button id="found">创建</button>
  </section>
</form>
  <div class="masklayer" style="display: none;">
    <section class="pao-tier">
      <span class="pao-close"></span>
      <dl >
        <dt class="tier-title club-blueq">已创建战队</dt>
        <dd class="tier-text">
          您已经开通竞赛资格，<br/>
          邀请好友快快参与竞赛吧！
        </dd>
        <dd class="tier-btn">确定</dd>
      </dl>
    </section>
  </div>
</body>
<script type="text/javascript">
  var uid = "{$uid}";
  if(!uid){
    window.location.href="paomeHome"
  }
  var sup = typeof jw === "object";
  if(typeof jw == "object") {
    jw.api('copy_current_url', JSON.stringify({'status': false}));
    jw.api('share_button', JSON.stringify({'status': true}));
    jw.api('set_share_info', JSON.stringify({
      'title': '我正在参与跑么杯争霸赛，快来加入我的战队赢取5000元奖励吧！',
      'description':'11月14日，就在虎扑跑步',
      'img_url':'http://irun.hupu.com/static/images/share/pao.png',
      'link_url':'{$staticHost}/paome_webIndex/paoShare',
    }));
  }
  $("#city").citySelect();
  $("#city").citySelect({
      url:"{$staticHost}/static/js/city.min.js",
      prov:"上海", //省份
      city:"虹口区", //城市
      nodata:"none" //当子集无数据时，隐藏select
  });
  // 城市二级联动
  function upload(obj)
  {
    var sum=obj.files.length;
    var str="";
    var url=window.URL.createObjectURL(obj.files[0]);
    var name=obj.files[0].name;

    $(".upLoad_btn").attr('src',url); 
   

  }
  // 上传logo
  /*提交表单*/
  $('#found').on('click',function(){
      $('#found').css('background','#23a4bd')
      if(!$('#myfile').val()){
          $('.tier-text').html("请上传战队LOGO");
          $('.tier-title,.tier-btn,.pao-close').hide();
          $('.masklayer').css('display','block');
          $('.masklayer').css('background','none');
          setTimeout("$('.masklayer').hide();",1000)
          $('#found').css('background','#54d8f2')
          return false;
      }

      if (!$("input[name='name']").val()) {
          
          $('.tier-text').html('给您的战队起个霸气的昵称吧');
          $('.tier-title,.tier-btn,.pao-close').hide();
          $('.masklayer').css('display','block');
          $('.masklayer').css('background','none');
          setTimeout("$('.masklayer').hide();",1000)
          $('#found').css('background','#54d8f2')
          return false;
      }

      if (!$("select[name='provice']").val() || !$("select[name='city']").val()){
          $('.tier-text').html('请选择省市');
          $('.tier-title,.tier-btn,.pao-close').hide();
          $('.masklayer').css('display','block');
          $('.masklayer').css('background','none');
          setTimeout("$('.masklayer').hide();",1000)
          $('#found').css('background','#54d8f2')
          return false;
      }
      $('.tier-title,.tier-btn,.pao-close').show();
      $(".bg-tm").show();
      $.ajax({
          type:'POST',
          url:$('#tr_form').attr('action'),
          data: new FormData($('#tr_form')[0]),
          processData: false,
          contentType: false,
          dataType:'json',
          success:function(d){
              if(d.status && d.status.code==200){
                $("#found").unbind();
                 $(".bg-tm").hide();
                window.location.href="paomeHome?tip=1"
              // $('.tier-title').html('已创建战队');
              // $('.tier-title').addClass('club-blue');
              // $('.tier-title').remove('club-orange');
              // $('.tier-text').html(' 您已经开通竞赛资格，<br/>请好友快快参与竞赛吧');
              //   $('.masklayer').css('display','block');
              //   $(".tier-btn,.pao-close").click(function(){
                    
              //     })
                return false;
              }else if(d.status && d.status.code==6007){
                 $(".bg-tm").hide();
                $('.tier-title').addClass('club-orange');
                $('.tier-title').remove('club-blue');
                $('.tier-title').html('您的正能量不足，无法创建俱乐部');
                $('.tier-text').html("需消耗正能量100<br/><span class='color-gray'>您的正能量当前剩余不足</span>");
                $('.masklayer').css('display','block');
                  $(".tier-btn,.pao-close").click(function(){
                    $('.masklayer').hide();
                  })
                return false;
              } else{
                  if(d.status.msg){
                      $(".bg-tm").hide();
                      $('.tier-title').html('错误提示');
                      $('.tier-title').addClass('club-orange');
                      $('.tier-title').remove('club-blue');
                      $('.tier-text').html(d.status.msg);
                      $('.masklayer').css('display','block');
                      $(".tier-btn,.pao-close").click(function(){
                        $('.masklayer').hide();
                      })
                      return false;
                  } else {
                      $(".bg-tm").hide();
                      $('.tier-title').html('错误提示');
                      $('.tier-title').addClass('club-orange');
                      $('.tier-text').html('创建失败');
                      $('.masklayer').css('display','block');
                      $(".tier-btn,.pao-close").click(function(){
                        $('.masklayer').hide();
                      })
                      return false;
                  }
              }
          }

      })

  })
  // $(".pao-close").click(function(){
  //   $(".masklayer").hide();
  // })

</script>
{template 'show/web-footer'}
